AppCompatEditText

A EditText which supports compatible features on older versions of the platform, including:

  • Allows dynamic tint of its background via the background tint methods in androidx.core.view.ViewCompat.
  • Allows setting of the background tint using backgroundTint and backgroundTintMode.
  • Allows setting a custom listener to handle insertion of content (e.g. pasting text or an image from the clipboard). This listener provides the opportunity to implement app-specific handling such as creating an attachment when an image is pasted.

This will automatically be used when you use EditText in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.

Constructors

Link copied to clipboard
constructor(@NonNull context: @NonNull Context)
constructor(@NonNull context: @NonNull Context, @Nullable attrs: @Nullable AttributeSet)
constructor(@NonNull context: @NonNull Context, @Nullable attrs: @Nullable AttributeSet, defStyleAttr: Int)

Functions

Link copied to clipboard
This should be accessed via getBackgroundTintList
Link copied to clipboard
This should be accessed via getBackgroundTintMode
Link copied to clipboard
This should be accessed via getCompoundDrawableTintList
Link copied to clipboard
This should be accessed via getCompoundDrawableTintMode Returns the blending mode used to apply the tint to the compound drawables, if specified.
Link copied to clipboard
@Nullable
open fun getText(): @Nullable Editable
Return the text that the view is displaying.
Link copied to clipboard
@RequiresApi(api = 26)
@NonNull
open fun getTextClassifier(): @NonNull TextClassifier
Returns the TextClassifier used by this TextView.
Link copied to clipboard
Link copied to clipboard
@Nullable
open fun onCreateInputConnection(@NonNull outAttrs: @NonNull EditorInfo): @Nullable InputConnection
If a listener is set, the returned InputConnection will use it to handle calls to commitContent.
Link copied to clipboard
open fun onDragEvent(event: DragEvent): Boolean
Link copied to clipboard
@Nullable
open fun onReceiveContent(@NonNull payload: @NonNull ContentInfoCompat): @Nullable ContentInfoCompat
Implements the default behavior for receiving content, which coerces all content to text and inserts into the view.
Link copied to clipboard
If a listener is set, uses it to execute the "Paste" and "Paste as plain text" menu actions.
Link copied to clipboard
open fun setBackgroundDrawable(@Nullable background: @Nullable Drawable)
Link copied to clipboard
Link copied to clipboard
open fun setCompoundDrawables(@Nullable left: @Nullable Drawable, @Nullable top: @Nullable Drawable, @Nullable right: @Nullable Drawable, @Nullable bottom: @Nullable Drawable)
Link copied to clipboard
open fun setCompoundDrawablesRelative(@Nullable start: @Nullable Drawable, @Nullable top: @Nullable Drawable, @Nullable end: @Nullable Drawable, @Nullable bottom: @Nullable Drawable)
Link copied to clipboard
open fun setEmojiCompatEnabled(enabled: Boolean)
Configure emoji fallback behavior using EmojiCompat.
Link copied to clipboard
open fun setKeyListener(@Nullable keyListener: @Nullable KeyListener)
Adds EmojiCompat KeyListener to correctly edit multi-codepoint emoji when they've been converted to spans.
Link copied to clipboard
open fun setSupportBackgroundTintList(@Nullable tint: @Nullable ColorStateList)
This should be accessed via setBackgroundTintList
Link copied to clipboard
This should be accessed via setBackgroundTintMode
Link copied to clipboard
open fun setSupportCompoundDrawablesTintList(@Nullable tintList: @Nullable ColorStateList)
This should be accessed via setCompoundDrawableTintList Applies a tint to the compound drawables.
Link copied to clipboard
This should be accessed via setCompoundDrawableTintMode Specifies the blending mode used to apply the tint specified by setSupportCompoundDrawablesTintList to the compound drawables.
Link copied to clipboard
open fun setTextAppearance(context: Context, resId: Int)
Link copied to clipboard
@RequiresApi(api = 26)
open fun setTextClassifier(@Nullable textClassifier: @Nullable TextClassifier)
Sets the TextClassifier for this TextView.